<?php

namespace app\admin\service\yun;

use app\admin\model\yun\YunPhoneDeviceGetRecord;
use app\admin\service\BaseService;


/**
 * 云挂机服务类
 */
class BoxYunDeviceGetRecordService extends BaseService
{

    /**
     * @var YunPhoneDeviceGetRecord
     */
    protected $model;

    public function __construct()
    {
        $this->model = new YunPhoneDeviceGetRecord();
    }

    public function getList(): array
    {
        $params = request()->param();
        $page  = request()->param('page', 1);
        $limit = request()->param('limit', 10);
        $time = $params['time_range'] ?? [];
        $where = [];
        if(!empty($time)){
            $where[] = ['create_time', 'between', [$time[0], $time[1]]];
        }
        
        $list  = $this->model
            ->where($where)
            ->order('id', 'desc')
            ->paginate($limit)->toArray();
        
        return array (
            "msg"   => '操作成功',
            "code"  => 0,
            "data"  => $list['data'],
            "count" => $list['total'],
        );
    }
}